package org.karesz.code.managedbean;

import java.util.Date;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.karesz.code.bean.TestBean;
import org.karesz.code.dao.TeamDAO;
import org.karesz.code.model.Team;

@ManagedBean
@SessionScoped
public class TeamManager {

	@EJB
	private TestBean bean;
	
	@EJB
	private TeamDAO<Team> teamDao;

	private Team selected;
	private String name = "Aron Dora";

	public String getName() {

		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Team getSelected() {
		if(selected == null) selected = new Team();
		return selected;
	}
	
	public String save(){
		selected.setTeamCreated(new Date());
		teamDao.save(selected);
		return "index.xhtml";
	}


}
